<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>
<html>
 <head>
    <title>批量生成生产日报</title>
    <!-- import css and js -->
	<%@ include file="/common/meta.jsp" %>
	<script src="${ctx}/js/ligerUI/js/plugins/ligerLayout.js" type="text/javascript"></script>
	<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
	<script type="text/javascript">
	var basic_Url="${ctx}/logic/prodaily";
	var basic_WUrl="logic/prodetail";
	var grid;
	function createSearch(){
		init(1,10,'100,100,100,100,100,100','8%');
		//第一行的数据
		addCommon(0,0,"lable","PI编号：");
		addCommon(0,1,"txtlike","zd003PiCode");
		addCommon(0,2,"lable","客户名称：");
		addCommon(0,3,"txtlike","zd004CustomerName");
		addCommon(0,4,"lable","客户编号：");
		addCommon(0,5,"txtlike","zd004CustomerName");
		addCommon(0,6,"lable","派工起始时间：");
		addCommon(0,7,"datestart","bizCreatorDate");
		addCommon(0,8,"lable","派工结束时间：");
		addCommon(0,9,"dateend","bizCreatorDate");
		
	}
	function searchAP(){
		multipleSearch("#table1",true,"",basic_Url+"/detaillist.do");
	}
	$(function(){
		grid = $("#table1").ligerGrid({
        	columns: [
                  { display: 'id', name:'id',hide:true},
                  { display: '派工单号', name: 'zd001FormCode', width: 120 },
                  { display: 'PI单号', name: 'zd003PiCode', width: 120},
                  { display: '客户名称', name: 'zd004CustomerName', width: 120},
                  { display: '客户编码', name: 'zd004CustomerCode', width: 120},
                  { display: '派工日期', name: 'bizCreatorDate', width: 120, render: function (item){
            		  var ctdate=new Date(item.bizCreatorDate);
            		  return formatDate(ctdate,"yyyy-MM-dd");
            	  }},
                  { display: '备注', name: 'zd009Remark', width: 120}
                 ],
                 usePager: true,pageSize:15,pageSizeOptions :[10,20,30,40,50], 
                 enabledSort:false,
                 url : basic_Url+"/detaillist.do",
                 width: "100%", height:"90%", checkbox: true, rownumbers:true,     
                 onDblClickRow : function (data, rowindex, rowobj){
                	 dsptEdit(data);
                 }
        });
		$("#pageloading").hide();
	});
	var show_Width=380;
	var show_Hight=400;
	function dsptEdit(data){
		var url = basic_WUrl+"/operate/edit/"+data.id+".do?dailyEx=yes";
		ShowIframeDialog("operate","派工",url,show_Width,show_Hight);
	}
	//批量生成日报
	function piliangSave(flagMark){
		var cRows = grid.getCheckedRows();
		if(cRows==null||cRows.length==0){
			$.dialog.alert("请选择需要生产日报的记录！");
			return false;
		}else{
			var detailIdStr = "";
			for(var i=0; i<cRows.length; i++){
				var cRow = cRows[i];
				if(i==0){
					detailIdStr = cRow.id;
				}else{
					detailIdStr = detailIdStr+","+cRow.id;
				}
			}
			$.ajax({
			      url: "${ctx}/logic/prodaily/pldailyToSave.do",
			      global: false,
			      type: "POST",
			      dataType: "json",
			      data: ({
			    	  detailIdStr : detailIdStr,
			    	  flagMark : flagMark
			      }),		     
			      success: function(msg){
			    	  if(msg.errorMsg=="SUCCESS"){
			    		  $.ligerDialog.success("批量生产日报成功","",function(){
			    			  multipleSearch("#table1",true,"",basic_Url+"/detaillist.do");
		    			  });
			    	  }
			    	  if(msg.errorMsg=="ERROR"){
			    		  $.dialog.alert("操作失败",function(){close();});
			    	  }
			   }
			});
		}
		
	}
	</script>
	
</head>
<body style="padding:10px" onload="createSearch()">
		<div id="layout1">
		   	<div id="pageHeader" class="pageHeader">
		        <div class="searchBar" id="multipleSearchDialog">
		        	<table class="table" width="100%" id="searchHeader" >  
		            	<tbody id="newbody">
		                </tbody>
		           	</table>
		            <div class="subBar">
		         		<ul>
			          		<li><div class="buttonActive">
				           	<div class="buttonContent">
				           		<button type="submit" id="btnSearch" onclick="searchAP()">查询</button>
				           	</div>
		          			</div></li>
		          			<li><a class="button" onclick="clearSearch()"><span>重置</span></a></li>
		          		</ul>
		           	</div>
		        </div>
		   </div>
		</div>
	    <div id="table1"></div>
	    <div class="formBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="button" id="save" onclick="piliangSave('PRODAILY_SAVE')">保存</button></div></div></li>
			    <li><div class="buttonActive"><div class="buttonContent"><button type="button" id="tijiao" onclick="piliangSave('PRODAILY_END')">提交</button></div></div></li>
			    <li><div class="button"><div class="buttonContent"><button type="button" class="print" onclick="CloseDialog()">关闭</button></div></div></li>
		    </ul>
	    </div>
</body>
</html>